//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CVertexLayout10.cpp>
///	@path	~/src/graphics/dx10/
///	@date	2008/12/28
///	@desc	.

#include "config/config.h"

#include "graphics/dx10/CVertexLayout10.h"
#include "graphics/dx10/CShaderAdapter10.h"

namespace xeres {
	
	IMPL_IOBJECT_CLASS( CVertexLayout10 );
	
	// CVertexLayout10
	CVertexLayout10::CVertexLayout10( RefWeak<IShaderAdapter> defaultAdapter , 
		std::vector<D3D10_INPUT_ELEMENT_DESC>& desc , const std::vector< Ref<CSlotLayout> >& slots )
		: m_defaultAdapter( defaultAdapter )
		, m_desc( desc )
		, m_slots( slots )
	{
		for( size_t i = 0 , total = m_desc.size() ; i < total ; ++i )
		{
			m_desc[i].SemanticName = _strdup( m_desc[i].SemanticName );
		}
	}
	// ~CVertexLayout10
	CVertexLayout10::~CVertexLayout10( void )
	{
		for( size_t i = 0 , total = m_desc.size() ; i < total ; ++i )
		{
			free( (void*)m_desc[i].SemanticName );
		}
	}
	// ApplyLayout
	void CVertexLayout10::ApplyLayout( RenderContext& rc )
	{
	}
	// GetSlotCount
	size_t CVertexLayout10::GetSlotCount( void )
	{
		return m_slots.size();
	}
	// GetSlot
	RefWeak<ISlotLayout> CVertexLayout10::GetSlot( size_t slot )
	{
		XS_ASSERT( slot < m_slots.size() );
		return m_slots[slot];
	}
	// GetDefaultAdapter
	RefWeak<IShaderAdapter> CVertexLayout10::GetDefaultAdapter( void )
	{
		return m_defaultAdapter;
	}

} // namespace xeres
